<?php

declare(strict_types=1);

namespace App\CustHub\Mapper;

use App\CustHub\Model\ChTalkFollowUpTask;
use Hyperf\Database\Model\Builder;
use Mine\Abstracts\AbstractMapper;

class ChTalkFollowUpTaskMapper extends AbstractMapper
{
    public function assignModel()
    {
        $this->model = ChTalkFollowUpTask::class;
    }

    public function handleSearch(Builder $query, array $params): Builder
    {
        $query->where('uid',$params['uid']);

        if(!empty($params['session_id'])){
            $query->where('session_id',$params['session_id']);
        }

        return $query;
    }

    public function handleOrder(Builder $query, ?array &$params = null): Builder
    {
        return $query->orderByDesc('id');
    }
}